// 日期字符串转成时间戳
function dateStrChangeTimeTamp(dateStr) {
  if (dateStr && typeof dateStr === 'string') {
    dateStr = dateStr.substring(0, 23)
    dateStr = dateStr.replace(/-/g, '/')
    const timeTamp = new Date(dateStr).getTime()
    return timeTamp
  } else {
    return 0
  }
}
// 精准到毫秒
function getNowTime(val) {
  const date = new Date(val)
  const hour = (date.getHours() - 8) < 10 ? '0' + (date.getHours() - 8) : date.getHours() - 8
  const minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
  const second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  const milliSeconds = date.getMilliseconds() // 毫秒
  const currentTime = hour + ':' + minute + ':' + second + '.' + milliSeconds
  return currentTime
}
export { dateStrChangeTimeTamp, getNowTime }
